/* eslint-disable vue/no-use-v-if-with-v-for */
<!-- xuwencheng  2022年6年29日18:00  这是我的wenzhangbianji -->
<!-- 事项处理 -->
<template>
  <el-dialog
    :append-to-body="true"
    :close-on-click-modal="false"
    :close-on-press-escape="false"
    :destory-on-close="true"
    :title="title"
    :visible.sync="dialogFormVisible"
    width="65%"
  >
    <el-form ref="form" label-width="200px" :model="form">
      <el-form-item label="姓名" prop="leaName">
        {{ form.leaName }}
      </el-form-item>

      <el-form-item label="领队经济人名称" prop="leaNickName">
        {{ form.leaNickName }}
      </el-form-item>
      <el-form-item label="领队简介" prop="leaderIntro">
        {{ form.leaderIntro }}
      </el-form-item>
      <el-form-item label="所属协作公司" prop="ofEnterprise">
        {{ form.ofEnterprise }}
      </el-form-item>
      <el-form-item label="是否是企业" prop="authEnterprise">
        <span v-if="form.authEnterprise == 1">企业</span>
        <span v-else>个人</span>
      </el-form-item>
      <el-form-item v-if="form.authEnterprise == 1" label="企业名称">
        <span>{{ form.enterpriseName }}</span>
      </el-form-item>
      <el-form-item label="创建时间" prop="createTime">
        {{ form.createTime }}
      </el-form-item>
      <el-form-item label="备注" prop="actOthor">
        {{ form.actOthor }}
      </el-form-item>
    </el-form>
    <el-form
      ref="formtwo"
      label-width="200px"
      :model="formtwo"
      :rules="rules"
      style="text-align: center"
    >
      <el-form-item
        v-if="form.leaderApplyCheck == 0"
        label="当前审核状态"
        style="display: inline-block"
      >
        <span>未审核</span>
      </el-form-item>

      <el-form-item
        v-if="form.leaderApplyCheck == 1"
        label="当前审核状态"
        style="display: inline-block"
      >
        <span>审核通过</span>
      </el-form-item>
      <el-form-item
        v-if="form.leaderApplyCheck == 2"
        label="当前审核状态"
        style="display: inline-block"
      >
        <span>审核未通过</span>
      </el-form-item>
      <el-form-item
        v-if="form.leaderApplyCheck == 0"
        label="审核状态"
        prop="checkValue"
        style="display: inline-block"
      >
        <el-select v-model="formtwo.checkValue" placeholder="请选择审核状态">
          <el-option
            v-for="item in options5"
            :key="item.id"
            clearable
            :label="item.creClasName"
            :value="item.id"
            @click.native="optosall(item)"
          />
        </el-select>
      </el-form-item>
      <!-- <el-form-item
        v-if="formtwo.checkValue == 0"
        label="驳回原因"
        prop="rejectReason"
      >
        <el-input v-model="formtwo.rejectReason" placeholder="请输入驳回原因" />
      </el-form-item> -->
    </el-form>
    <el-button
      class="baocun"
      size="medium"
      type="primary"
      @click="save('formtwo')"
    >
      保存
    </el-button>
  </el-dialog>
</template>

<script>
  /* eslint-disable*/
  import {
    doAdd,
    serach,
    starareacrewjob,
    serachtwo,
    agerange,
    doEdit,
    checkrecruit,
  } from '@/api/userManagement'
  import { roleId } from '@/api/yanyuan'
  import { stringify } from 'querystring'
  import { city } from '../guanli/js/city'

  //import { number } from 'echarts'
  export default {
    name: 'search',

    data() {
      return {
        formtwo: {
          leaderId: '', //领队id
          jobId: '', //事项id
          checkValue: '', //审核的结果
        },
        jiezhial: '', //截止日期
        checked: true,
        optionswo: city,
        selectedOptions: [],
        keyWord: '', //关键词
        keyWordtwo: '', //领队关键词
        token: '',
        imageUrl: '',
        neirong: '', //查询剧组内容
        neirongtwo: [], //查询领队内容
        imageUrltwo: '', //摩卡
        value: true,
        value1: true,
        dialogVisible: false,
        disabled: false,
        options1: [],
        options2: [],
        options3: [],
        options5: [
          {
            id: 1,
            creClasName: '审核通过',
          },
          {
            id: 0,
            creClasName: '审核未通过',
          },
        ], //身份
        options7: [], //选择区域
        options9: [], //选择年龄
        valueone: '', //查询
        valuetwo: '',
        shujv: '暂无数据',
        shujvtwo: '暂无数据', //查询领队
        form: {
          actorClassifyIds: [],
          crwCityName: '', //城市名称
          crewNeed: '1', //是否选择领队
          crwAreaName: '', //区域名称不能为空,
          teamLeaderIds: [], //指定领队的情况下，领队的id
          needTeamleader: '0', //是否指定领队0-不指定 1-指定
          // deadline: '', //截至日期时间戳不能为空
          crwMale: '1', //是否需要男性演员 0-否 1-是
          crwFemale: '1', //是否需要女性演员 0-否 1-是
          jobCityId: '', //城市id
        },
        activated() {
          if (this.$refs.MaskVideo.src) this.$refs.MaskVideo.play()
        },
        deactivated() {
          if (this.$refs.MaskVideo.src) this.$refs.MaskVideo.pause()
        },

        rules: {
          rejectReason: [
            { required: true, trigger: 'blur', message: '请输入驳回原因' },
          ],
          checkValue: [
            { required: true, trigger: 'change', message: '请选择审核状态' },
          ],
        },
        title: '',
        dialogFormVisible: false,
      }
    },
    created() {
      this.token = this.$store.getters['user/token']
      this.fetchDatatwo()
      this.fetchDatathree()
      this.fetchDatafour()
    },
    methods: {
      enterprise(e) {
        this.form.crewId = e.id

        this.neirong = e.crewName
      },
      enterprisetwo(e) {
        this.form.teamLeaderIds = e.id
        console.log(this.form.teamLeaderIds)
      },

      cascar(e) {
        //选择城市
        this.form.crwCityName =
          // this.$refs['cascader'].getCheckedNodes()[0].pathLabels[0] +
          // '--' +
          // this.$refs['cascader'].getCheckedNodes()[0].pathLabels[1] +
          // '--' +
          this.$refs['cascader'].getCheckedNodes()[0].pathLabels[2]

        this.form.jobCityId = e[2]
      },
      beforeAvatarUpload(file) {
        const isJPG = file.type === 'image/jpeg'
        const isLt2M = file.size / 1024 / 1024 < 2
        if (!isLt2M) {
          this.$message.error('上传头像图片大小不能超过 2MB!')
        }
        return true
      },
      beforeAvatarUploadtwo(file) {
        const isJPG = file.type === 'image/jpeg'
        const isLt2M = file.size / 1024 / 1024 < 2
        if (!isLt2M) {
          this.$message.error('上传头像图片大小不能超过 2MB!')
        }
        return true
      },
      choose(e) {
        this.form.crewTheme = e.themeName
        this.form.crewThemeId = e.id
      },
      chooseone(e) {}, //所属角色
      choosetwo(e) {
        //选择区域

        this.form.crwAreaName = e.areaName
      },
      chooseonetwo(e) {
        //选择年龄区间
        console.log(e)
        this.form.ageId = e.id
        this.form.needAge = e.ageRange
      },
      handleChange(a) {
        this.form.particulars = a
      },
      handleAvatarSuccess(res, file, fileList) {
        this.imageUrl = URL.createObjectURL(file.raw)
        console.log(res)
        this.form.actorPicture = res.data
      },
      handleAvatarSuccesstwo(res, file, fileList) {
        this.imageUrltwo = URL.createObjectURL(file.raw)
        this.form.moka = res.data
      },
      showEdit(row, jobId) {
        if (!row) {
          this.title = '添加'
        } else {
          this.title = '处理审核状态'
          this.form = Object.assign({}, row)
          this.formtwo.leaderId = row.id
          this.formtwo.jobId = jobId
        }
        this.dialogFormVisible = true
      },
      optosall(e) {
        this.formtwo.checkValue = e.id
        console.log(this.formtwo.checkValue)
      },
      closetwo() {
        //关闭处理
        this.formtwo.checkValue = ''

        this.dialogFormVisible = false
      },
      close() {
        let userId = this.form.userId
        this.$refs['form'].resetFields()
        this.form = this.$options.data().form
        if (!this.form.id) {
          this.form.userId = userId
        }

        this.dialogFormVisible = false
        this.imageUrl = ''
        this.imageUrltwo = ''
        // this.form = ''
      },
      sethealth(e) {
        this.form.health = e
      },
      sethealthtwo(e) {
        this.form.workType = e
      },
      save(formName) {
        this.$refs[formName].validate((valid) => {
          if (valid) {
            const msg = checkrecruit(this.formtwo)
            msg.then((res) => {
              this.$emit('fetch-data')

              this.$baseMessage(res.msg, 'success', 'vab-hey-message-success')

              this.close()
            })
          } else {
            return false
          }
        })
      },

      queryDatass() {
        this.queryData()
      },
      queryData() {
        //chaxun
        this.disabled = true
        let keyWord = this.keyWord
        const msg = serach({
          keyWord: keyWord,
        })
        msg.then((res) => {
          if (res.msg == 'success') {
            this.options1 = res.data
          }
        })
      },
      queryDatatwo() {
        //查询领队
        let keyWord = this.keyWordtwo
        const msg = serachtwo({
          keyWord: keyWord,
        })

        msg.then((res) => {
          if (res.msg == 'success') {
            this.options3 = res.data
          }
        })
      }, //查询领队
      async fetchDatatwo() {
        let queryForm = {}
        const res = await roleId(queryForm)
        this.options2 = res.data
        console.log(res)
      },
      async fetchDatathree() {
        //选择区域
        let queryForm = {}
        const res = await starareacrewjob(queryForm)
        this.options7 = res.data
        console.log(res)
      },
      async fetchDatafour() {
        //选择年0
        let queryForm = {}
        const res = await agerange(queryForm)
        this.options9 = res.data
        console.log(res)
      },
      handleCheckedCitiesChange(value) {
        console.log(value)
        console.log(this.form.teamLeaderIds)
        // this.neirongtwo = value
        let checkedCount = value.length
        // this.checkAll = checkedCount === this.cities.length
        // this.isIndeterminate =
        //   checkedCount > 0 && checkedCount < this.cities.length
      },
    },
  }
</script>
<style>
  /* .huakuai {
    position: relative;
    left: 96%;
  } */
  .avatar-uploader .el-upload {
    position: relative;
    overflow: hidden;
    cursor: pointer;
    border: 1px dashed #d9d9d9;
    border-radius: 6px;
  }
  .avatar-uploader .el-upload:hover {
    border-color: #409eff;
  }
  .avatar-uploader-icon {
    width: 178px;
    height: 178px;
    font-size: 28px;
    line-height: 178px;
    color: #8c939d;
    text-align: center;
  }
  .avatar {
    display: block;
    width: 178px;
    height: 178px;
  }
  .baocun {
    width: 100%;
    height: 100%;
  }
</style>
